package com.atguigu.lease.web.app.config;

import com.atguigu.lease.web.app.interceptor.AuthenticationAdminInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/***
 * App拦截器配置类
 */
@Configuration
@PropertySource("classpath:application.yml")
public class appInterceptorConfig implements WebMvcConfigurer {

    @Autowired
    private AuthenticationAdminInterceptor authenticationAdminInterceptor;

    @Value("${app.auth.path-patterns.include}")
    private String addPathPatterns;//拦截谁，路径
    @Value("${app.auth.path-patterns.exclude}")
    private String excludePathPatterns;//不拦截谁，路径


    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(authenticationAdminInterceptor)
                .addPathPatterns(addPathPatterns)
                .excludePathPatterns(excludePathPatterns);
    }
}
